package com.itheima.mapper;

import com.itheima.pojo.Category;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CategoryMapper {
    //新增
    @Insert("insert into category(province_name,create_user, create_time, update_time) " +
            "values(#{provinceName},#{createUser},now(),now())")
    void add(Category category);

    //查询所以文章列表
    @Select("select * from category")
    List<Category> list();

    //根据id查询文章分类信息
    @Select("select * from category where id=#{id}")
    Category findById(Integer id);

    //更新文章分类信息
    @Update("update category set province_name=#{categoryName},create_user=#{categoryAlias},update_time=#{updateTime}" +
            " where id = #{id}")
    void update(Category category);

    // 根据id删除文章分类
    @Delete("delete from category where id=#{id}")
    void delete(Integer id);
}
